#pragma once

#include "Singleton.h"
#include "ObjectFactory.h"

//////////////////////////////////////////////////////////////////////////

class CAnyEditor;
class GEOMDBAPI CEditorCreator
{
public:
	virtual CAnyEditor* Create(void) = 0;
};

//////////////////////////////////////////////////////////////////////////
class CAnyView;

class GEOMDBAPI CEditorFactory
	: public ATools::TSingleton<CEditorFactory>,
	  public ATools::TObjectFactory<CAnyEditor, CString, CEditorCreator>
{
public:
	CEditorFactory(void);
	~CEditorFactory(void);
	void Initialize(void);
	CAnyEditor* CreateEditor(const CString& szId, CAnyView* pView);
};

inline CEditorFactory& GetEditorFactory()
{
	return CEditorFactory::Instance();
}

//////////////////////////////////////////////////////////////////////////

class GEOMDBAPI CRegEditorHelper
{
public:
	CRegEditorHelper(const CString& guid, CEditorCreator* pEditorCreator);
	~CRegEditorHelper();
protected:
	void RegisterEditor(CEditorCreator* pEditorCreator);
	const CString& m_Guid;
};

#define REGISTERE_EDITOR(Editor) \
	static CRegEditorHelper s_regEditorHelper##Editor(Editor::GetID(),\
		new ATools::TObjectCreator<Editor, CEditorCreator>());


